import { NodeTypeEnum } from "@src/modules/trigger/model";
import { uuid } from "@src/util/lang/string";


// 前端渲染的时候的 node
export class ProcessNode{
    public type: NodeTypeEnum = NodeTypeEnum.NODE;
    public name: string = '';
    public content: string = '';
    public children: ProcessNode[] = [];
    public uniqueId: string = uuid();
    public id?: string | undefined;
    public options: Record<string, any> = {};
    public parentNode: ProcessNode | null  = null

    constructor(option: TriggerNode) {
        const { id = undefined, uniqueId, options = {}, type = NodeTypeEnum.NODE, name = '' } = option
        this.id = id
        this.uniqueId = uniqueId
        this.options = options
        this.type = type
        this.name = name
    }
}


// 服务端返回的 edge
export class TriggerNode {
    public uniqueId: string = uuid()
    public id!: string | undefined
    public options: Record<string, any> = {}
    public type: NodeTypeEnum = NodeTypeEnum.NODE
    public name?: string = '';

    constructor(option: ProcessNode) {
        const { uniqueId, id, options, type, name } = option
        this.uniqueId = uniqueId
        this.id = id
        this.options = options
        this.type = type
        this.name = name
    }
}

